Import('env')
import os.path

def check_pyllvm():
    """
    Returns true if llvm is installed
    """
    try:
        env.backtick('llvm-config --libs core')
        return True
    except OSError:
        return False


def check_qt3():
    return os.path.exists('/usr/include/qt3/qt.h')

TESTS = []

if check_pyllvm():
    TESTS.append( 
    ('pyllvm', {
        'PYXXPATH' : [env.backtick('llvm-config --includedir').strip()],
        'CXXFLAGS' : env.backtick('llvm-config --cxxflags').strip().split(),
        'LINKFLAGS' : env.backtick('llvm-config --libs all').strip().split(),
    }))

if check_qt3():
    TESTS.append(
    ('qt3', {
        'PYXXPATH' : ['/usr/include/qt3'],
        'CPPPATH' : ['/usr/include/qt3/'],
        'LIBS' : ['qt-mt']
    }))

import sys
from distutils.sysconfig import get_python_inc

env = env.Clone()

env['ENV']['PYTHONPATH'] = env.subst("$CXX-$VARIANT/lib")


examples = [ env.RunTests(name, name, args) for name, args in TESTS ]
env.Alias('examples', examples)
Return('examples')
